/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package aso.upna.threads;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author triki
 */
public class ClientListenerThread implements Runnable
{


    public void run() {
        try {
            
            DatagramSocket s = new DatagramSocket();
            DatagramPacket dp = new DatagramPacket(new byte[100],100);
            System.out.println("Socket UDP a la espera");
            System.out.println("local port: "+s.getLocalPort());
            System.out.println("port: "+s.getPort());
            
            s.receive(dp);
            System.out.println("Comienza a recibir");
            
            while(dp.getLength() > 0)
            {
                s.receive(dp);
            }
            System.out.println("se ha terminado");
        } catch (IOException ex) {
            Logger.getLogger(ClientListenerThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
